﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Sector7.Medical.EntityType;
using Sector7.Framework.DB;
using System.Data.SqlClient;

namespace Sector7.Medical.DAO.Standard
{
    /// <summary>
    /// 药剂数据访问对象
    /// </summary>
    public class DrugFormDAO : DAOBase<M7_DrugForm>, IDrugFormDAO
    {
        /// <summary>
        /// 获取所有数据
        /// </summary>
        /// <returns></returns>
        public override List<M7_DrugForm> ReadAll()
        {
            string sql = @"
                SELECT *
                    FROM M7_DrugForm";

            using (DBHelper helper = new DBHelper())
            {
                List<M7_DrugForm> drugFormList = new List<M7_DrugForm>();

                SqlDataReader reader = helper.ExecuteQuery(sql);
                while (reader.Read())
                {
                    var drugForm = new M7_DrugForm();
                    DBUtil.ReadData(reader, drugForm);

                    drugFormList.Add(drugForm);
                }

                return drugFormList;
            }
        }
    }
}
